<!DOCTYPE html>
<html lang="en">
<head>
<!-- Bootstrap core JavaScript
    ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- 资源引用页面 -->
<#include "common/_commresource.html"/>
<title>随意论坛</title>
</head>

<body>
	<!--  顶部引用页面 -->
	<#include "common/_commtop.html"/>
	<!-- start site's main content area -->
	<section class="content-wrap">
		<div class="container">
			<div class="row">
				<main class="col-md-8 main-content">
				<article id="" class="post">
					<table class="table table-bordered table-hover">
						<thead>
							<tr>
								<th>id</th>
								<th>任务名称</th>
								<th>创建人</th>
								<th>当前状态</th>
								<th>是否加载</th>
								<th>最近执行时间</th>
								<th>备注</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<#list result as x>
							<tr>
								<td>${x['jobId']!''}</td>
								<td>${x['jobName']!''}</td>
								<td>${x['createMan']!''}</td>
								<td><#if x['runningStatus']==2>运行中<#elseif x['runningStatus']==1>等待<#else>停用</#if></td>
								<td><#if x['loadRunning']==1>是<#else>否</#if></td>
								<td>${x['executeTime']!''}</td>
								<td>${x['remarker']!''}</td>
								<td>
<a title="立即启动"><span class="glyphicon glyphicon-play" onclick="immediatelyJob(${x['jobId']!''})"></span></a>
<span title="停止" class="glyphicon glyphicon-stop" onclick="stopJob(${x['jobId']!''})"></span>
<a title="删除"><span class="glyphicon glyphicon-trash" onclick="removeJob(${x['jobId']!''})"></span></a>
<span class="glyphicon glyphicon-edit" onclick="editJob(${x['jobId']!''})" title="编辑"></span>
								</td>
							</tr>
							</#list>
						</tbody>
					</table>
				 <a href="${request.contextPath}/jobMessage/jobConfig"
				class="btn btn-default btn-block" style="margin-left:90%;width: 10%">增加</a>
				</article>
				<#include "common/_paginate.html"/>
				<@paginate currentPage=pageNum totalPage=totalPages
				actionUrl="${request.contextPath}/jobMessage/jobManage?pageSize=5&keyword=${top_key_word!}&pageNum="/> </main>
				<#include "common/_commright.html"/>
			</div>
		</div>
	</section>
	<!-- 页脚 start -->
	<#include "common/_friendshiplink.html"/>
	<!-- 页脚 end -->
	<script>
	function immediatelyJob(id){
		$.ajax({
		    type: "post",
		    dataType: 'json',
		    url: '${request.contextPath}/jobMessage/immediatelyJob',
		    data: {"id":id},
		    success:function(data){
		    	if(data.status==200){
		    		layer.msg(data.msg, {icon: 1,time:2000});
		    		setTimeout("location.replace(location.href)",2000); //延时2秒执行
			    }
		    }
		});
	}
	
		function stopJob(id){
			$.ajax({
			    type: "post",
			    dataType: 'json',
			    url: '${request.contextPath}/jobMessage/stopJob',
			    data: {"id":id},
			    success:function(data){
			    	if(data.status==200){
			    		layer.msg(data.msg, {icon: 1,time:2000});
				    }
			    }
			});
		}
	
		function removeJob(id){
			$.ajax({
			    type: "post",
			    dataType: 'json',
			    url: '${request.contextPath}/jobMessage/removeJob',
			    data: {"id":id},
			    success:function(data){
			    	if(data.status==200){
			    		layer.msg(data.msg, {icon: 1,time:2000});
			    		setTimeout("location.replace(location.href)",2000); //延时2秒执行
				    }
			    }
			});
		}

		function editJob(id){
			window.location.href="${request.contextPath}/jobMessage/editJob?id="+id; 
		}
	</script>	
</body>
</html>